import { App } from 'antd'
import { copy } from '@/lib/utils'

/**
 * 复制文本并显示成功消息
 */
export function useCopy() {
  const { message } = App.useApp()
  const copyWithMessage = useCallback(
    (text: string) => {
      copy(text)
      void message.success('已复制')
    },
    [message],
  )
  return copyWithMessage
}
